From 9c8f5fffd055122c5b6e8bf4432b214df59b865a Mon Sep 17 00:00:00 2001 From: dinesh Date: Wed, 1 Jul 2015 01:14:46 +0530 Subject: [PATCH] Add tests for all targets without names --- tests/test_cargo_test.rs | 166 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 3e34f7c9c..f9473fd20 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -721,6 +721,172 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured ", compiling = COMPILING, running = RUNNING, dir = p.url()))); }); +test!(bin_without_name { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "syntax" + version = "0.0.1" + authors = [] + + [lib] + test = false + doctest = false + + [[bin]] + path = "src/main.rs" + "#) + .file("src/lib.rs", " + pub fn foo() {} + ") + .file("src/main.rs", " + extern crate syntax; + + fn main() {} + + #[test] + fn test() { syntax::foo() } + "); + + assert_that(p.cargo_process("test"), + execs().with_status(101) + .with_stderr(&format!("\ +failed to parse manifest at `[..]` + +Caused by: + binary target bin.name is required"))); +}); + +test!(bench_without_name { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "syntax" + version = "0.0.1" + authors = [] + + [lib] + test = false + doctest = false + + [[bench]] + path = "src/bench.rs" + "#) + .file("src/lib.rs", " + pub fn foo() {} + ") + .file("src/main.rs", " + extern crate syntax; + + fn main() {} + + #[test] + fn test() { syntax::foo() } + ") + .file("src/bench.rs", " + #![feature(test)] + extern crate syntax; + extern crate test; + + #[bench] + fn external_bench(_b: &mut test::Bencher) {} + "); + + assert_that(p.cargo_process("test"), + execs().with_status(101) + .with_stderr(&format!("\ +failed to parse manifest at `[..]` + +Caused by: + bench target bench.name is required"))); +}); + +test!(test_without_name { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "syntax" + version = "0.0.1" + authors = [] + + [lib] + test = false + doctest = false + + [[test]] + path = "src/test.rs" + "#) + .file("src/lib.rs", r#" + pub fn foo() {} + pub fn get_hello() -> &'static str { "Hello" } + "#) + .file("src/main.rs", " + extern crate syntax; + + fn main() {} + + #[test] + fn test() { syntax::foo() } + ") + .file("src/test.rs", r#" + extern crate syntax; + + #[test] + fn external_test() { assert_eq!(syntax::get_hello(), "Hello") } + "#); + + assert_that(p.cargo_process("test"), + execs().with_status(101) + .with_stderr(&format!("\ +failed to parse manifest at `[..]` + +Caused by: + test target test.name is required"))); +}); + +test!(example_without_name { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "syntax" + version = "0.0.1" + authors = [] + + [lib] + test = false + doctest = false + + [[example]] + path = "examples/example.rs" + "#) + .file("src/lib.rs", " + pub fn foo() {} + ") + .file("src/main.rs", " + extern crate syntax; + + fn main() {} + + #[test] + fn test() { syntax::foo() } + ") + .file("examples/example.rs", r#" + extern crate syntax; + + fn main() { + println!("example1"); + } + "#); + + assert_that(p.cargo_process("test"), + execs().with_status(101) + .with_stderr(&format!("\ +failed to parse manifest at `[..]` + +Caused by: + example target example.name is required"))); +}); + test!(bin_there_for_integration { let p = project("foo") .file("Cargo.toml", r#" -- 2.30.2